package com.nbjtjc.safe.api.safe;

import cn.hutool.core.collection.CollectionUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.mapper.danger.DangerInspectPublicMapper;
import com.nbjtjc.safe.model.danger.DangerInspectPublic;
import com.nbjtjc.safe.model.safe.SafeDangerInspectTask;
import com.nbjtjc.safe.service.danger.DangerInspectPublicService;
import com.nbjtjc.safe.service.safe.SafeDangerInspectTaskServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/safe/task")
@CrossOrigin("*")
public class SafeDangerInspectTaskController {

    @Autowired
    private SafeDangerInspectTaskServiceImpl taskService;

    @Autowired
    private DangerInspectPublicService dangerInspectPublicService;

    @GetMapping("/getTaskInfo")
    public Result getTaskInfo(){
        return taskService.getTaskInfo();
    }
    @PostMapping("/search")
    public Result search(@RequestBody SafeDangerInspectTask task){
        return taskService.search(task);
    }

    @PostMapping("/add")
    public Result add(@RequestBody SafeDangerInspectTask task){
        return taskService.add(task);
    }

    @PostMapping("/publicTaskPlan")
    public Result publicTaskPlan(@RequestBody SafeDangerInspectTask task){
        return taskService.publicTaskPlan(task);
    }

    @PostMapping("/update")
    public Result update(@RequestBody SafeDangerInspectTask task){
        return taskService.update(task);
    }
    @PostMapping("/addTaskTable")
    public Result addTaskTable(@RequestBody DangerInspectPublic  inspectPublic){
        return taskService.addTaskTable(inspectPublic);
    }

    @PostMapping("/deleteTaskTable")
    public Result deleteTaskTable(@RequestBody  DangerInspectPublic inspectPublic){
        return taskService.deleteTaskTable(inspectPublic.getId());
    }

    @PostMapping("/delete")
    public Result deleteTask(@RequestBody  SafeDangerInspectTask task){
        return taskService.delete(task.getId());
    }
}
